/*
 * Created on 13 avr. 2005
 * Group of SIMPACK 2004-2005
 * Coded by TRAN Thuy Tien & NGOUNDJI Gerard
 * 
 */
package communication.thirdLayer;
import objects.Station;
import java.io.Serializable;

/**
 * @author SIMPACK 2005
 */

public class RoutingTableEntry implements Serializable {
	
/**
 * period of time after each of which if this RoutingTableEntry hasn't been used
 * we'll disactivate it
 */
	
/** searched destination  
 */
	private Station destination;
	
/**
 * The route should be taken to reach the destination 
 */
	private Station nextNode;
	
/**
 * Sequence number of this route
 */
	private int sequence;
	
/**
 * number of steps to reach the destination
 */
	private int stepCount;
	
/**
 * this boolean tells you if this route is still valid.
 * Because if a route hasn't been used or renewed
 * for a certain time, it will be turned into invalid
 */


/**
 * The time from the moment that a RoutingtableEntry is renewed
 */
	private int timer;
	
//---------------------------------------------------------------
/**
 * Constructor
 */
	public RoutingTableEntry(	Station dest, 
								Station ligne, 
								int seq, 
								int nbpas){
		 this.destination=dest;
		 this.nextNode=ligne;
		 this.sequence=seq;
		 this.stepCount=nbpas;
		 this.timer=0;
	}
//-----Fonctions d'acces-------------------------------	


/**
 * Print a routing table entry
 */
public String toString(){
	
	String entry;

	        
	if(this == null){
			entry = " No entry in the routing table ";
		}
		 else {entry = "destination : "+ destination.getName()
	 			  + "; line : " +nextNode.getName()+
				  "; sequence : "+sequence+
				  "; hop: "+ stepCount;
		 }
				return entry;      
				}

	
	public Station getDestination(){
		return this.destination;
	}
	
	public Station getNextNode(){
		return this.nextNode;
	}
	
	public int getStepCount(){
		return this.stepCount;
	}
	
	public int getSequence(){
		return this.sequence;
	}
	
	public int getTimer(){
		return this.timer;
	}
	
	/**
	 * set the timer to 0
	 */
	public void razTimer(){
		this.timer=0;
	}
	
/**
 * We add to timer a value of n
 * This method will be called in the Simulator.calculate()
 * @param n
 */
	public void timerIncrement(int n){
		timer+=n;
	}
	

	
	public static void main(String[] args) {
	}
}
